<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="####1. 实现一次定位1). 导入头文件1#import &amp;lt;CoreLocation/CoreLocation.h&amp;gt;">
<meta name="keywords" content="Android、iOS、Web、React Native">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS-MapView(定位)">
<meta property="og:url" content="http://yoursite.com/blog/2018/08/06/iOS-Special-Function/iOS-MapView(定位)/index.html">
<meta property="og:site_name" content="凌浩雨_博客">
<meta property="og:description" content="####1. 实现一次定位1). 导入头文件1#import &amp;lt;CoreLocation/CoreLocation.h&amp;gt;">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-eb93a7fe2c0143e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-08-06T10:55:07.119Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS-MapView(定位)">
<meta name="twitter:description" content="####1. 实现一次定位1). 导入头文件1#import &amp;lt;CoreLocation/CoreLocation.h&amp;gt;">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/3110861-eb93a7fe2c0143e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/blog/2018/08/06/iOS-Special-Function/iOS-MapView(定位)/"/>





  <title>iOS-MapView(定位) | 凌浩雨_博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">凌浩雨_博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/blog/blog/2018/08/06/iOS-Special-Function/iOS-MapView(定位)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="凌浩雨">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="凌浩雨_博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">iOS-MapView(定位)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-06T18:01:38+08:00">
                2018-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>####1. 实现一次定位<br>1). 导入头文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">#import &lt;CoreLocation/CoreLocation.h&gt;</span><br></pre></td></tr></table></figure></p>
<a id="more"></a>
<p>2). 实现<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;CoreLocation/CoreLocation.h&gt;</span><br><span class="line"></span><br><span class="line">@interface ViewController () &lt;CLLocationManagerDelegate&gt;</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    // 1. 创建CLLocationManager</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    // 2. 请求用户授权，还需配置Plist，配置键为NSLocationWhenInUseUsageDescription，值为提示用户的信息</span><br><span class="line">    if ([self.mgr respondsToSelector:@selector(requestWhenInUseAuthorization)]) &#123;</span><br><span class="line">        [self.mgr requestWhenInUseAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    // 3. 设置代理</span><br><span class="line">    self.mgr.delegate = self;</span><br><span class="line">    // 4. 调用开始方法定位</span><br><span class="line">    [self.mgr startUpdatingLocation];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 代理方法</span><br><span class="line">// 当完成位置更新的时候调用，会频繁调用</span><br><span class="line">- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray&lt;CLLocation *&gt; *)locations &#123;</span><br><span class="line">    // 获取位置信息</span><br><span class="line">    CLLocation *location = locations.lastObject;</span><br><span class="line">    NSLog(@&quot;locations: %@&quot;, location);</span><br><span class="line">    // 5. 停止定位</span><br><span class="line">    [self.mgr stopUpdatingLocation];</span><br><span class="line">    // locations: &lt;+37.78583400,-122.40641700&gt; +/- 5.00m (speed -1.00 mps / course -1.00) @ 1/19/18, 3:19:43 PM China Standard Time</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>####2. 持续定位<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;CoreLocation/CoreLocation.h&gt;</span><br><span class="line">@interface ViewController () &lt;CLLocationManagerDelegate&gt;</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    // 创建CLLocationManager</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    // 请求永久权限，还需配置Plist，配置键为NSLocationAlwaysUsageDescription，值为提示用户的信息</span><br><span class="line">    if ([self.mgr respondsToSelector:@selector(requestAlwaysAuthorization)]) &#123;</span><br><span class="line">        [self.mgr requestAlwaysAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    // 设置代理</span><br><span class="line">    self.mgr.delegate = self;</span><br><span class="line">    // 开始定位</span><br><span class="line">    [self.mgr startUpdatingLocation];</span><br><span class="line">    // 设置位置筛选器，节省电量</span><br><span class="line">    self.mgr.distanceFilter = 10;</span><br><span class="line">    // 设置期望精度</span><br><span class="line">    self.mgr.desiredAccuracy = kCLLocationAccuracyThreeKilometers;</span><br><span class="line">    // 期望精度可选值</span><br><span class="line">//    kCLLocationAccuracyBest;</span><br><span class="line">//    kCLLocationAccuracyNearestTenMeters;</span><br><span class="line">//    kCLLocationAccuracyHundredMeters;</span><br><span class="line">//    kCLLocationAccuracyKilometer;</span><br><span class="line">//    kCLLocationAccuracyThreeKilometers;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 代理方法</span><br><span class="line">- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray&lt;CLLocation *&gt; *)locations &#123;</span><br><span class="line">    CLLocation *location = locations.lastObject;</span><br><span class="line">    NSLog(@&quot;---%@&quot;, location);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>####3. 临时授权及位置差<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;CoreLocation/CoreLocation.h&gt;</span><br><span class="line">@interface ViewController () &lt;CLLocationManagerDelegate&gt;</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    // 请求定位权限，还需配置Plist，配置键为NSLocationWhenInUseUsageDescription，值为提示用户的信息</span><br><span class="line">    if ([self.mgr respondsToSelector:@selector(requestWhenInUseAuthorization)]) &#123;</span><br><span class="line">        [self.mgr requestWhenInUseAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    // 请求临时授权, 先判断iOS系统版本。需要配置plist，新增UIBackgroundModes键，增加后时一个数组，然后第一项名字设置为&quot;App registers for location updates&quot;</span><br><span class="line">    if ([UIDevice currentDevice].systemVersion.floatValue &gt;= 9.0) &#123;</span><br><span class="line">        // 变现为应用程序进入后台时可以继续更新当前位置</span><br><span class="line">        self.mgr.allowsBackgroundLocationUpdates = YES;</span><br><span class="line">    &#125;</span><br><span class="line">    self.mgr.delegate = self;</span><br><span class="line">    [self.mgr startUpdatingLocation];</span><br><span class="line">    </span><br><span class="line">    // 计算两点之间的位置</span><br><span class="line">    CLLocation *location1 = [[CLLocation alloc] initWithLatitude:40 longitude:116];</span><br><span class="line">    CLLocation *location2 = [[CLLocation alloc] initWithLatitude:34.27 longitude:108.93];</span><br><span class="line">    // 比较的是直线距离</span><br><span class="line">    CLLocationDistance distance = [location1 distanceFromLocation:location2];</span><br><span class="line">    NSLog(@&quot;distance: %f&quot;, distance);</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 代理方法</span><br><span class="line">- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray&lt;CLLocation *&gt; *)locations &#123;</span><br><span class="line">    CLLocation *location = locations.lastObject;</span><br><span class="line">    NSLog(@&quot;latitude: %f, longitude: %f&quot;, location.coordinate.latitude, location.coordinate.longitude);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p><img src="http://upload-images.jianshu.io/upload_images/3110861-eb93a7fe2c0143e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="临时权限进入后台如图.png"></p>
<p>####4. 地理编码和反地理编码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;CoreLocation/CoreLocation.h&gt;</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    [self encode];</span><br><span class="line">    [self decode];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">// 地理编码</span><br><span class="line">- (void)encode &#123;</span><br><span class="line">    // 1. 创建一个CLGeocoder对象</span><br><span class="line">    CLGeocoder *geocoder = [CLGeocoder new];</span><br><span class="line">    // 2. 实现地理编码</span><br><span class="line">    [geocoder geocodeAddressString:@&quot;乌鲁木齐&quot; completionHandler:^(NSArray&lt;CLPlacemark *&gt; * _Nullable placemarks, NSError * _Nullable error) &#123;</span><br><span class="line">        // 处理出错</span><br><span class="line">        if (error || placemarks.count == 0) &#123;</span><br><span class="line">            NSLog(@&quot;解析出错&quot;);</span><br><span class="line">            return;</span><br><span class="line">        &#125;</span><br><span class="line">        // 遍历数组</span><br><span class="line">        for (CLPlacemark *placeMark in placemarks) &#123;</span><br><span class="line">            NSLog(@&quot;latitude: %f&quot;, placeMark.location.coordinate.latitude);</span><br><span class="line">            NSLog(@&quot;longitude: %f&quot;, placeMark.location.coordinate.longitude);</span><br><span class="line">            NSLog(@&quot;name: %@&quot;, placeMark.name);</span><br><span class="line">//            latitude: 43.792818</span><br><span class="line">//            longitude: 87.617733</span><br><span class="line">//            name: Xinjiang Urumqi</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">// 反地理编码</span><br><span class="line">- (void)decode &#123;</span><br><span class="line">    // 1. 创建CLGeocoder对象</span><br><span class="line">    CLGeocoder *geocoder = [CLGeocoder new];</span><br><span class="line">    // 2. 创建一个CLLocation对象</span><br><span class="line">    CLLocation *location = [[CLLocation alloc] initWithLatitude:43.792818 longitude:87.617733];</span><br><span class="line">    // 3. 反地理编码</span><br><span class="line">    [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray&lt;CLPlacemark *&gt; * _Nullable placemarks, NSError * _Nullable error) &#123;</span><br><span class="line">        // 处理出错</span><br><span class="line">        if (error || placemarks.count == 0) &#123;</span><br><span class="line">            NSLog(@&quot;解析出错&quot;);</span><br><span class="line">            return;</span><br><span class="line">        &#125;</span><br><span class="line">        // 遍历数组</span><br><span class="line">        for (CLPlacemark *placeMark in placemarks) &#123;</span><br><span class="line">            NSLog(@&quot;latitude: %f&quot;, placeMark.location.coordinate.latitude);</span><br><span class="line">            NSLog(@&quot;longitude: %f&quot;, placeMark.location.coordinate.longitude);</span><br><span class="line">            NSLog(@&quot;name: %@&quot;, placeMark.name);</span><br><span class="line">//            latitude: 43.794040</span><br><span class="line">//            longitude: 87.620584</span><br><span class="line">//            name: No.37 Zhongshan Road</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;];</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>####5. MapView使用<br>1). 导入Mapkit.framework<br>点击工程-&gt;General-&gt;Linked Frameworks and Libraries，输入MapKit，点击Add。<br>2). 示例<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> #pragma mark 1. 显示用户位置 (掌握)</span><br><span class="line"> #pragma mark 2. 设置地图显示类型 (掌握)</span><br><span class="line"> #pragma mark 3. 根据用户位置显示对应的大头针信息(掌握)</span><br><span class="line"> #pragma mark 4. 设置以用户所在位置为中心点(掌握)</span><br><span class="line"> #pragma mark 5. 获取地图显示区域改变时的中心点坐标及显示跨度 (了解)</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;MapKit/MapKit.h&gt;</span><br><span class="line"></span><br><span class="line">@interface ViewController ()&lt;MKMapViewDelegate&gt;</span><br><span class="line">@property (weak, nonatomic) IBOutlet MKMapView *mapView;</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    </span><br><span class="line">    //1. 创建位置管理器</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    </span><br><span class="line">    //2. 请求授权 --&gt; plist</span><br><span class="line">    if ([self.mgr respondsToSelector:@selector(requestWhenInUseAuthorization)]) &#123;</span><br><span class="line">        [self.mgr requestWhenInUseAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    //3. 设置显示用户位置</span><br><span class="line">    //Tracking: 跟踪</span><br><span class="line">    /**</span><br><span class="line">     MKUserTrackingModeNone = 0,</span><br><span class="line">     MKUserTrackingModeFollow,             定位</span><br><span class="line">     MKUserTrackingModeFollowWithHeading,  定位并且显示方向</span><br><span class="line">     */</span><br><span class="line">    self.mapView.userTrackingMode = MKUserTrackingModeFollow;</span><br><span class="line">    </span><br><span class="line">    //4. 设置代理 --&gt; 获取用户位置信息</span><br><span class="line">    self.mapView.delegate = self;</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    /**</span><br><span class="line">     iOS9新增属性</span><br><span class="line">     */</span><br><span class="line">    //1. 设置交通状况</span><br><span class="line">    self.mapView.showsTraffic = YES;</span><br><span class="line">    </span><br><span class="line">    //2. 设置指南针(默认就是YES), 屏幕旋转后会出现, 如果点击会校正方向</span><br><span class="line">    self.mapView.showsCompass = YES;</span><br><span class="line">    </span><br><span class="line">    //3. 设置比例尺</span><br><span class="line">    self.mapView.showsScale = YES;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 切换地图类型</span><br><span class="line">- (IBAction)mapTypeChangeClick:(UISegmentedControl *)sender &#123;</span><br><span class="line">    /**</span><br><span class="line">     MKMapTypeStandard = 0,    默认</span><br><span class="line">     MKMapTypeSatellite,       卫星</span><br><span class="line">     MKMapTypeHybrid,          混合</span><br><span class="line">     MKMapTypeSatelliteFlyover NS_ENUM_AVAILABLE(10_11, 9_0), 下面两个属性, 中国区无用</span><br><span class="line">     MKMapTypeHybridFlyover NS_ENUM_AVAILABLE(10_11, 9_0),</span><br><span class="line">     */</span><br><span class="line">    // 设置地图类型 , 一般要使用默认, 要么使用混个, 单纯的卫星图没有意义.</span><br><span class="line">    switch (sender.selectedSegmentIndex) &#123;</span><br><span class="line">        case 0:</span><br><span class="line">            self.mapView.mapType = MKMapTypeStandard;</span><br><span class="line">            break;</span><br><span class="line">        case 1:</span><br><span class="line">            self.mapView.mapType = MKMapTypeSatellite;</span><br><span class="line">            break;</span><br><span class="line">        case 2:</span><br><span class="line">            self.mapView.mapType = MKMapTypeHybrid;</span><br><span class="line">            break;</span><br><span class="line">        case 3:</span><br><span class="line">            self.mapView.mapType = MKMapTypeSatelliteFlyover;</span><br><span class="line">            break;</span><br><span class="line">        case 4:</span><br><span class="line">            self.mapView.mapType = MKMapTypeHybridFlyover;</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/** </span><br><span class="line"> 完成用户位置更新的时候 调用</span><br><span class="line"> MKUserLocation : 大头针模型</span><br><span class="line"> */</span><br><span class="line">- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation</span><br><span class="line">&#123;</span><br><span class="line">    //需求: 显示大头针信息 --&gt; 反地理编码实现</span><br><span class="line">    </span><br><span class="line">    //1. 创建一个CLGeocoder对象</span><br><span class="line">    CLGeocoder *geocoder = [CLGeocoder new];</span><br><span class="line">    </span><br><span class="line">    //2. 实现反地理编码方法</span><br><span class="line">    [geocoder reverseGeocodeLocation:userLocation.location completionHandler:^(NSArray&lt;CLPlacemark *&gt; * _Nullable placemarks, NSError * _Nullable error) &#123;</span><br><span class="line">        </span><br><span class="line">        //3.1 防错处理</span><br><span class="line">        if (placemarks.count == 0 || error) &#123;</span><br><span class="line">            return;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        //3.2 获取对象</span><br><span class="line">        CLPlacemark *placemark = placemarks.lastObject;</span><br><span class="line">        </span><br><span class="line">        //3.3 设置标题为城市信息</span><br><span class="line">        userLocation.title = placemark.locality;</span><br><span class="line">        </span><br><span class="line">        //3.4 设置子标题为详细地址</span><br><span class="line">        userLocation.subtitle = placemark.name;</span><br><span class="line">    &#125;];</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 点击此按钮, 返回用户所在的位置</span><br><span class="line">- (IBAction)backUserLocationClick:(id)sender &#123;</span><br><span class="line">    //1. 设置中心点坐标</span><br><span class="line">    //self.mapView.centerCoordinate = self.mapView.userLocation.location.coordinate;</span><br><span class="line">    </span><br><span class="line">    //2. 设置范围的属性</span><br><span class="line">    //2.1 获取坐标</span><br><span class="line">    CLLocationCoordinate2D coordinate = self.mapView.userLocation.location.coordinate;</span><br><span class="line">    </span><br><span class="line">    //2.2 设置显示范围 --&gt; 为了跟系统默认的跨度保持一致, 我们可以打印region的span值来获取, 然后设置即可</span><br><span class="line">    //1° ~ 111KM</span><br><span class="line">    MKCoordinateSpan span = MKCoordinateSpanMake(0.021252, 0.014720);</span><br><span class="line">    </span><br><span class="line">    //2.3 设置范围属性 默认没有动画</span><br><span class="line">    //self.mapView.region = MKCoordinateRegionMake(coordinate, span);</span><br><span class="line">    </span><br><span class="line">    //设置范围方法 可以设置动画</span><br><span class="line">    [self.mapView setRegion:MKCoordinateRegionMake(coordinate, span) animated:YES];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> 当地图显示区域发生改变后, 会调用的方法</span><br><span class="line"> */</span><br><span class="line">- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated</span><br><span class="line">&#123;</span><br><span class="line">    //获取默认的显示大小 --&gt; span</span><br><span class="line">    NSLog(@&quot;latitudeDelta : %f, longitudeDelta: %f&quot;, mapView.region.span.latitudeDelta, mapView.region.span.longitudeDelta);</span><br><span class="line">    </span><br><span class="line">    // latitudeDelta : 0.021252, longitudeDelta: 0.014720</span><br><span class="line">    // latitudeDelta : 0.010626, longitudeDelta: 0.007360</span><br><span class="line">    // latitudeDelta : 0.005313, longitudeDelta: 0.003680</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 放大地图</span><br><span class="line">- (IBAction)zoomInClick:(id)sender &#123;</span><br><span class="line">    //1. Delta 跨度缩小一倍</span><br><span class="line">    //region : 是当前地图显示的区域</span><br><span class="line">    CGFloat latitudeDelta = self.mapView.region.span.latitudeDelta * 0.5;</span><br><span class="line">    CGFloat longitudeDelta = self.mapView.region.span.longitudeDelta * 0.5;</span><br><span class="line">    </span><br><span class="line">    //2. 重设region属性</span><br><span class="line">    [self.mapView setRegion: MKCoordinateRegionMake(self.mapView.centerCoordinate, MKCoordinateSpanMake(latitudeDelta, longitudeDelta)) animated:YES];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 缩小地图</span><br><span class="line">- (IBAction)zoomOutClick:(id)sender &#123;</span><br><span class="line">    //1. Delta 跨度放大一倍</span><br><span class="line">    //region : 是当前地图显示的区域</span><br><span class="line">    CGFloat latitudeDelta = self.mapView.region.span.latitudeDelta * 2;</span><br><span class="line">    CGFloat longitudeDelta = self.mapView.region.span.longitudeDelta * 2;</span><br><span class="line">    </span><br><span class="line">    //2. 重设region属性</span><br><span class="line">    [self.mapView setRegion: MKCoordinateRegionMake(self.mapView.region.center, MKCoordinateSpanMake(latitudeDelta, longitudeDelta)) animated:YES];</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>####6. 点击添加大头针<br>1). 新建类MyAnnotationModel，并实现协议MKAnnotation，属性从协议中拷贝，并删除readonly。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> 1. 导入框架 MapKit</span><br><span class="line"> 2. 遵守协议 MKAnnotation</span><br><span class="line"> 3. 设置属性 直接去协议中拷贝--&gt;删掉readonly</span><br><span class="line"> */</span><br><span class="line">#import &lt;Foundation/Foundation.h&gt;</span><br><span class="line">#import &lt;MapKit/MapKit.h&gt;</span><br><span class="line"></span><br><span class="line">@interface MyAnnotationModel : NSObject&lt;MKAnnotation&gt;</span><br><span class="line">@property (nonatomic) CLLocationCoordinate2D coordinate;</span><br><span class="line">@property (nonatomic, copy, nullable) NSString *title;</span><br><span class="line">@property (nonatomic, copy, nullable) NSString *subtitle;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>2). MapView中点击添加大头针<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;MapKit/MapKit.h&gt;</span><br><span class="line">#import &quot;MyAnnotationModel.h&quot;</span><br><span class="line"></span><br><span class="line">@interface ViewController ()&lt;MKMapViewDelegate&gt;</span><br><span class="line"></span><br><span class="line">@property (weak, nonatomic) IBOutlet MKMapView *mapView;</span><br><span class="line"></span><br><span class="line">/** 位置管理器*/</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line"></span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    </span><br><span class="line">    //1. 创建位置管理器</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    </span><br><span class="line">    //2. 请求授权</span><br><span class="line">    if ([self.mgr respondsToSelector:@selector(requestWhenInUseAuthorization)]) &#123;</span><br><span class="line">        [self.mgr requestWhenInUseAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    //3. 跟踪用户位置</span><br><span class="line">    self.mapView.userTrackingMode = MKUserTrackingModeFollow;</span><br><span class="line">    </span><br><span class="line">    //4. 设置地图的代理</span><br><span class="line">    self.mapView.delegate = self;    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">#pragma mark 地图的代理方法</span><br><span class="line">/**</span><br><span class="line"> 只要添加了大头针模型, 就会来到这个方法, 设置并返回对应的View</span><br><span class="line"> */</span><br><span class="line">- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation</span><br><span class="line">&#123;</span><br><span class="line">    </span><br><span class="line">    //如果返回nil, 就代表用户没有自定义的需求, 所有的View样式由系统处理</span><br><span class="line">    //MKUserLocation: 系统专门显示用户位置的大头针模型</span><br><span class="line">    //MyAnnotationModel: 自定义的类</span><br><span class="line">    </span><br><span class="line">    //1. 如果发现是显示用户位置的大头针模型,  就返回nil</span><br><span class="line">    if ([annotation isKindOfClass:[MKUserLocation class]]) &#123;</span><br><span class="line">        return nil;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    //2. 自定义大头针View --&gt; 跟Cell的创建几乎一样</span><br><span class="line">    static NSString *ID = @&quot;annoView&quot;;</span><br><span class="line">    </span><br><span class="line">    //MKAnnotationView : 默认image属性没有赋值</span><br><span class="line">    //MKPinAnnotationView : 子类是默认有View的</span><br><span class="line">    MKPinAnnotationView *annoView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:ID];</span><br><span class="line">    </span><br><span class="line">    if (annoView == nil) &#123;</span><br><span class="line">        annoView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:ID];</span><br><span class="line">        </span><br><span class="line">        /**</span><br><span class="line">         MKPinAnnotationColorRed</span><br><span class="line">         MKPinAnnotationColorGreen,</span><br><span class="line">         MKPinAnnotationColorPurple</span><br><span class="line">         */</span><br><span class="line">        </span><br><span class="line">        //3. 设置颜色, iOS9新增</span><br><span class="line">        annoView.pinTintColor = [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0  blue:arc4random_uniform(256) / 255.0  alpha:1];</span><br><span class="line">        </span><br><span class="line">        //4. 设置动画掉落</span><br><span class="line">        annoView.animatesDrop = YES;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    return annoView;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">#pragma mark 点击添加大头针</span><br><span class="line">- (void)touchesBegan:(NSSet&lt;UITouch *&gt; *)touches withEvent:(UIEvent *)event</span><br><span class="line">&#123;</span><br><span class="line">    //1. 获取点击地图的点</span><br><span class="line">    CGPoint point = [[touches anyObject] locationInView:self.mapView];</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    //2. 将点击的点转换成经纬度</span><br><span class="line">    CLLocationCoordinate2D coordinate = [self.mapView convertPoint:point toCoordinateFromView:self.mapView];</span><br><span class="line">    </span><br><span class="line">    //3. 添加大头针</span><br><span class="line">    MyAnnotationModel *annotationModel = [MyAnnotationModel new];</span><br><span class="line">    </span><br><span class="line">    annotationModel.coordinate = coordinate;</span><br><span class="line">    annotationModel.title = @&quot;北京市&quot;;</span><br><span class="line">    annotationModel.subtitle = @&quot;北京市一个迷人的城市&quot;;</span><br><span class="line">    </span><br><span class="line">    [self.mapView addAnnotation:annotationModel];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>3). 自定义大头针图标</p>
<ul>
<li><p>为自定义的大头针添加属性</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">/** 图像属性*/</span><br><span class="line">@property (nonatomic, copy, nullable) NSString *icon;</span><br></pre></td></tr></table></figure>
<ul>
<li>在返回自定义大头针的时候为属性赋值<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">#pragma mark 地图的代理方法</span><br><span class="line">/**</span><br><span class="line"> 只要添加了大头针模型, 就会来到这个方法, 设置并返回对应的View</span><br><span class="line"> */</span><br><span class="line">- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation</span><br><span class="line">&#123;</span><br><span class="line">    </span><br><span class="line">    //如果返回nil, 就代表用户没有自定义的需求, 所有的View样式由系统处理</span><br><span class="line">    //MKUserLocation: 系统专门显示用户位置的大头针模型</span><br><span class="line">    //MyAnnotationModel: 自定义的类</span><br><span class="line">    </span><br><span class="line">    //1. 如果发现是显示用户位置的大头针模型,  就返回nil</span><br><span class="line">    if ([annotation isKindOfClass:[MKUserLocation class]]) &#123;</span><br><span class="line">        return nil;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    //2. 自定义大头针View --&gt; 跟Cell的创建几乎一样</span><br><span class="line">    static NSString *ID = @&quot;annoView&quot;;</span><br><span class="line">    </span><br><span class="line">    //MKAnnotationView : 默认image属性没有赋值</span><br><span class="line">    //MKPinAnnotationView : 子类是默认有View的</span><br><span class="line">    MKAnnotationView *annoView = [mapView dequeueReusableAnnotationViewWithIdentifier:ID];</span><br><span class="line">    </span><br><span class="line">    if (annoView == nil) &#123;</span><br><span class="line">        annoView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:ID];</span><br><span class="line">        // 设置图像  --&gt; MVC</span><br><span class="line">        //annoView.image = [UIImage imageNamed:@&quot;苍老师&quot;];</span><br><span class="line">    &#125;</span><br><span class="line">     // 设置图像  --&gt; MVC</span><br><span class="line">    MyAnnotationModel *myAnnotation = annotation;</span><br><span class="line">    annoView.image =  [UIImage imageNamed:myAnnotation.icon];</span><br><span class="line">    </span><br><span class="line">    return nil;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
<li><p>在大头针图像出现之前设置图片位置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">#pragma mark 此方法在添加大头针的时候就会调用, 并且, 在图像出现之前</span><br><span class="line">- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray&lt;MKAnnotationView *&gt; *)views</span><br><span class="line">&#123;</span><br><span class="line">    //NSLog(@&quot;count: %zd&quot;,views.count);</span><br><span class="line">    for (MKAnnotationView * annoView in views) &#123;</span><br><span class="line">        </span><br><span class="line">        //0. 处理显示用户位置的大头针View, 不要增加动画</span><br><span class="line">        if ([annoView.annotation isKindOfClass:[MKUserLocation class]]) &#123;</span><br><span class="line">            continue;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        //1. 记录原本的位置</span><br><span class="line">        CGRect endFrame = annoView.frame;</span><br><span class="line">        </span><br><span class="line">        //2. 将View的Y值改为0, 重设Frame</span><br><span class="line">        annoView.frame = CGRectMake(endFrame.origin.x, 0, endFrame.size.width, endFrame.size.height);</span><br><span class="line">        </span><br><span class="line">        //3. 将位置还原, 执行动画效果</span><br><span class="line">        [UIView animateWithDuration:0.25 animations:^&#123;</span><br><span class="line">            annoView.frame = endFrame;</span><br><span class="line">        &#125;];</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>####7. 地图导航-调用系统<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;MapKit/MapKit.h&gt;</span><br><span class="line"></span><br><span class="line">@interface ViewController ()</span><br><span class="line">@property (weak, nonatomic) IBOutlet UITextField *destinationTF;</span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">#pragma mark 导航按钮点击</span><br><span class="line">- (IBAction)navigateClick:(id)sender &#123;</span><br><span class="line">   </span><br><span class="line">    //1. 创建CLGeocoder对象</span><br><span class="line">    CLGeocoder *geocoder = [CLGeocoder new];</span><br><span class="line">    </span><br><span class="line">    //2. 调用地理编码方法</span><br><span class="line">    [geocoder geocodeAddressString:self.destinationTF.text completionHandler:^(NSArray&lt;CLPlacemark *&gt; * _Nullable placemarks, NSError * _Nullable error) &#123;</span><br><span class="line">        </span><br><span class="line">        //3 防错处理</span><br><span class="line">        if (placemarks.count == 0 || error) &#123;</span><br><span class="line">            NSLog(@&quot;您输入的地址我们没找到!!!&quot;);</span><br><span class="line">            </span><br><span class="line">            return;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        //遍历数组获取数据 --&gt; 正地理编码, 可能重名, 所以数组数量大于1, 一定要给列表提示用户选择</span><br><span class="line">        NSMutableArray *arr = [NSMutableArray array];</span><br><span class="line">        </span><br><span class="line">        for (CLPlacemark *pm in placemarks) &#123;</span><br><span class="line">            //4. 获取地表对象 暂取最后一个</span><br><span class="line">            </span><br><span class="line">            //5. 创建MKPlacemark对象</span><br><span class="line">            MKPlacemark *mkpm = [[MKPlacemark alloc] initWithPlacemark:pm];</span><br><span class="line">            </span><br><span class="line">            //6. 创建一个MKMapItem</span><br><span class="line">            MKMapItem *destItem = [[MKMapItem alloc] initWithPlacemark:mkpm];</span><br><span class="line">            </span><br><span class="line">            [arr addObject:destItem];</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        //7. 调用open类方法, 打开导航</span><br><span class="line">        //WithItems: 传入要定位的点</span><br><span class="line">        //launchOptions: 导航参数</span><br><span class="line">        NSDictionary *options = @&#123;MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsMapTypeKey : @(MKMapTypeHybrid), MKLaunchOptionsShowsTrafficKey : @(YES)&#125;;</span><br><span class="line">        [MKMapItem openMapsWithItems:arr launchOptions:nil];</span><br><span class="line">    &#125;];</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>
<p>####8. 地图导航-自己画线<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &lt;MapKit/MapKit.h&gt;</span><br><span class="line"></span><br><span class="line">@interface ViewController ()&lt;MKMapViewDelegate&gt;</span><br><span class="line"></span><br><span class="line">@property (weak, nonatomic) IBOutlet MKMapView *mapView;</span><br><span class="line"></span><br><span class="line">/** 位置管理器--&gt; 要定位必须用这个属性*/</span><br><span class="line">@property (nonatomic, strong) CLLocationManager *mgr;</span><br><span class="line"></span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> 如果是地图画线, 无法在模拟器中运行 --&gt; iOS8以后无法在模拟器中运行</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    </span><br><span class="line">    // 创建位置管理器并授权</span><br><span class="line">    self.mgr = [CLLocationManager new];</span><br><span class="line">    if ([UIDevice currentDevice].systemVersion.floatValue &gt;= 8.0) &#123;</span><br><span class="line">        [self.mgr requestWhenInUseAuthorization];</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    // 设置代理</span><br><span class="line">    self.mapView.delegate = self;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 导航按钮点击</span><br><span class="line">- (IBAction)navigateClick:(id)sender &#123;</span><br><span class="line">    </span><br><span class="line">    // 回收键盘</span><br><span class="line">    [self.view endEditing:YES];</span><br><span class="line">   </span><br><span class="line">    //1. 创建CLGeocoder对象</span><br><span class="line">    CLGeocoder *geocoder = [CLGeocoder new];</span><br><span class="line">    </span><br><span class="line">    //2. 调用地理编码方法</span><br><span class="line">    [geocoder geocodeAddressString:&quot;西山&quot; completionHandler:^(NSArray&lt;CLPlacemark *&gt; * _Nullable placemarks, NSError * _Nullable error) &#123;</span><br><span class="line">        </span><br><span class="line">        //3 防错处理</span><br><span class="line">        if (placemarks.count == 0 || error) &#123;</span><br><span class="line">            return;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        //遍历数组获取数据 --&gt; 正地理编码, 可能重名, 所以数组数量大于1, 一定要给列表提示用户选择</span><br><span class="line">        </span><br><span class="line">        //4. 获取地表对象 暂取最后一个</span><br><span class="line">        CLPlacemark *pm = placemarks.lastObject;</span><br><span class="line">        </span><br><span class="line">        //5. 创建MKPlacemark对象</span><br><span class="line">        MKPlacemark *mkpm = [[MKPlacemark alloc] initWithPlacemark:pm];</span><br><span class="line">        </span><br><span class="line">        //6.1 创建一个终点MKMapItem</span><br><span class="line">        MKMapItem *destinationItem = [[MKMapItem alloc] initWithPlacemark:mkpm];</span><br><span class="line">        </span><br><span class="line">        //6.2 创建一个起点MKMapItem</span><br><span class="line">        MKMapItem *souceItem = [MKMapItem mapItemForCurrentLocation];</span><br><span class="line">        </span><br><span class="line">        //7. 创建一个方向请求对象 --&gt; 相当于拼接网址 --&gt; 需要传入参数: 起点和终点</span><br><span class="line">        MKDirectionsRequest *request = [MKDirectionsRequest new];</span><br><span class="line"></span><br><span class="line">        //7.1 设置终点</span><br><span class="line">        request.destination = destinationItem;</span><br><span class="line"></span><br><span class="line">        //7.2 设置起点</span><br><span class="line">        request.source = souceItem;</span><br><span class="line">        </span><br><span class="line">        </span><br><span class="line">        //8. 创建方向对象 --&gt; 创建一个请求对象</span><br><span class="line">        MKDirections *direction = [[MKDirections alloc] initWithRequest:request];</span><br><span class="line">        </span><br><span class="line">        //9. 计算路径 --&gt; 处理网络请求的结果</span><br><span class="line">        [direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse * _Nullable response, NSError * _Nullable error) &#123;</span><br><span class="line">            </span><br><span class="line">            //10.1 防错处理</span><br><span class="line">            if (response.routes.count == 0 || error) &#123;</span><br><span class="line">                NSLog(@&quot;没有找到对应的路线&quot;);</span><br><span class="line">                return ;</span><br><span class="line">            &#125;</span><br><span class="line">            //10.2 遍历数组, 获取数据</span><br><span class="line">            //MKRoute : 路线对象</span><br><span class="line">            for (MKRoute *route in response.routes) &#123;</span><br><span class="line">                </span><br><span class="line">                //polyline : 多段线</span><br><span class="line">                </span><br><span class="line">                //11. 获取折线信息</span><br><span class="line">                MKPolyline *polyline = route.polyline;</span><br><span class="line">                </span><br><span class="line">                //12. 添加到地图上</span><br><span class="line">                //Overlay : 遮盖物</span><br><span class="line">                [self.mapView addOverlay:polyline];</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;];</span><br><span class="line">    &#125;];  </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">#pragma mark 如果添加了遮盖物, 就需要调用此方法, 来设置渲染</span><br><span class="line">- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id&lt;MKOverlay&gt;)overlay</span><br><span class="line">&#123;</span><br><span class="line">    //1. 创建一个折线渲染物对象</span><br><span class="line">    MKPolylineRenderer *polyline = [[MKPolylineRenderer alloc] initWithOverlay:overlay];</span><br><span class="line">    </span><br><span class="line">    polyline.fillColor = [UIColor redColor];</span><br><span class="line">    //2. 设置线条颜色 --&gt; 必须设置, 否则看不见</span><br><span class="line">//    polyline.strokeColor = [UIColor blueColor];</span><br><span class="line">    </span><br><span class="line">    //3. 设置线条宽度</span><br><span class="line">    polyline.lineWidth = 10;</span><br><span class="line">    return polyline;</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/08/06/iOS-Special-Function/iOS-LocalAuthentication(指纹识别)/" rel="next" title="iOS-LocalAuthentication(指纹识别)">
                <i class="fa fa-chevron-left"></i> iOS-LocalAuthentication(指纹识别)
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/08/06/iOS-Special-Function/iOS-Motion(传感器)/" rel="prev" title="iOS-Motion(传感器)">
                iOS-Motion(传感器) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blog/images/avatar.jpeg"
                alt="凌浩雨" />
            
              <p class="site-author-name" itemprop="name">凌浩雨</p>
              <p class="site-description motion-element" itemprop="description">专业从事于移动端开发，Android与iOS均有涉及，主做Android开发与React Native开发</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">393</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">凌浩雨</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
